package cn.wenhe9.novel.controller.front;

import cn.wenhe9.novel.constant.ApiRouterConsts;
import cn.wenhe9.novel.domain.dto.NewsInfoDto;
import cn.wenhe9.novel.result.ResultResponse;
import cn.wenhe9.novel.service.NewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 新闻模块 API 接口
 *
 * @author DuJinliang
 * 2022/5/18
 */
@Api(tags = "新闻模块 API 接口")
@RestController
@RequestMapping(ApiRouterConsts.API_FRONT_NEWS_URL_PREFIX)
public class NewsController {

    @Resource
    private NewsService newsService;

    /**
     * 最新新闻列表查询接口
     */
    @ApiOperation("最新新闻列表查询接口")
    @GetMapping("latest_list")
    public ResultResponse<List<NewsInfoDto>> listLatestNews() {
        return newsService.listLatestNews();
    }

    /**
     * 新闻信息查询接口
     */
    @GetMapping("{id}")
    @ApiOperation("新闻信息查询接口")
    public ResultResponse<NewsInfoDto> getNews(@PathVariable Long id) {
        return newsService.getNews(id);
    }
}
